package com.boarsoft.boar.soagov.face.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.boarsoft.bean.ReplyInfo;
import com.boarsoft.boar.entity.FaceInfo;
import com.boarsoft.boar.soagov.face.FaceBiz;
import com.boarsoft.common.Authorized;
import com.boarsoft.common.dao.PagedResult;
import com.boarsoft.common.util.JsonUtil;

@RestController
@RequestMapping("/face")
public class FaceAction {
	@Autowired
	private FaceBiz faceBiz;

	/**
	 * 查询所有接口
	 */
	@RequestMapping("/list")
	// @Authorized(code = "face.list")
	public ReplyInfo<Object> list(String key, String orderBy, int pageNo, int pageSize) {
		PagedResult<FaceInfo> fiPr = faceBiz.list(key, orderBy, pageNo, pageSize);
		return new ReplyInfo<Object>(true, JsonUtil.from(fiPr));
	}

	@RequestMapping("/save.do")
	@Authorized(code = "face.save")
	public ReplyInfo<Object> save(FaceInfo c) {
		faceBiz.save(c);
		return ReplyInfo.SUCCESS;
	}

	@RequestMapping("/delete.do")
	@Authorized(code = "face.delete")
	public ReplyInfo<Object> delete(String id) {
		faceBiz.delete(id);
		return ReplyInfo.SUCCESS;
	}

	@RequestMapping("/get.do")
	@Authorized(code = "face.get")
	public ReplyInfo<Object> get(String id) {
		FaceInfo a = faceBiz.get(id);
		return new ReplyInfo<Object>(true, JsonUtil.from(a));
	}
}